//
//  CommWebViewController.m
//  WhereToTravel
//
//  Created by dllo on 15/10/15.
//  Copyright © 2015年 zhoushengmin. All rights reserved.
//

#import "CommWebViewController.h"
#import "MBProgressHUD.h"
#define W [[UIScreen mainScreen]bounds].size.width/375
#define H [[UIScreen mainScreen]bounds].size.height /667
@interface CommWebViewController ()<UIWebViewDelegate>
@property(nonatomic,retain)UIWebView *webview;

@end

@implementation CommWebViewController

// 视图的出现将tabbar显示,消失就隐藏
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.tabBarController.tabBar.hidden = YES;
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    self.tabBarController.tabBar.hidden = YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createWeb];
    
    // 左上角返回图标
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"返回"] style:(UIBarButtonItemStylePlain) target:self action:@selector(leftAction:)];
    // Do any additional setup after loading the view.
}

// 返回
- (void)leftAction:(UIBarButtonItem *)barButton {
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)createWeb
{
    self.webview = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, 375 * W, 667 * H)];
    [self.view addSubview:self.webview];
    self.webview.delegate = self;
    
    NSURL*url=[NSURL URLWithString:self.url];
    NSURLRequest*reuqest=[NSURLRequest requestWithURL:url];
    [self.webview loadRequest:reuqest];
    
}

-(void)webViewDidStartLoad:(UIWebView *)webView
{
    
    [MBProgressHUD showHUDAddedTo:webView animated:YES];
    
    
}

-(void)webViewDidFinishLoad:(UIWebView *)webView
{
    [MBProgressHUD hideHUDForView:webView animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
